﻿@*<script src="~/admui-13945148017-1592211513218/vendor/bootstrap-sweetalert/sweetalert.min.js"></script>*@
@*<script src="~/admui-13945148017-1592211513218/themes/global/js/components/bootstrap-sweetalert.min.js"></script>*@
@*<script src="~/admui-13945148017-1592211513218/js/examples/components/advanced/bootbox-sweetalert.min.js"></script>*@
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-sweetalert/sweetalert.js"></script>
<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-sweetalert.js"></script>
<script src="~/admui-13945148017-1592211513218/public/js/examples/components/advanced/bootbox-sweetalert.js"></script>
<script src="~/admui-13945148017-1592211513218/public/js/tsk/sweetalert.min.js"></script>

<script>
    $(document).ready(function () {
        $("#SpanXiTong").click();
        //修改下拉框绑定1
        $('#SelZhanQu').bind('input propertychange', function () {
            $("#SelZhanDui").empty();
            $.ajax({
                url: "../RenYuan/GetSelZhanDui",
                data: { "ZhanQuId": $("#SelZhanQu").val() },
                type: "post",
                dataType: "json",
                success: function (response) {
                    if ($("#SelZhanQu").val() != 0) {
                        var ddl = $("#SelZhanDui");
                        var opt0 = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt0);
                    }
                    $(response).each(function (key) {
                        if (response[key].id.toString() == '1') {
                            var opt = $("<option></option>").text("请选择").val(response[key].id);
                            ddl.append(opt);
                        } else if (response[key].id.toString() == "") {
                            var opt = $("<option selected='selected'></option>").text(response[key].ZhanDuiMingCheng).val(response[key].id);
                            ddl.append(opt);
                        } else {
                            var opt = $("<option></option>").text(response[key].ZhanDuiMingCheng).val(response[key].id);
                            ddl.append(opt);
                        }
                    })
                    console.log(response);
                }
            });
        })
        //修改下拉框绑定2
        $('#SelZhanQu2').bind('input propertychange', function () {
            $("#SelZhanDui2").empty();
            $.ajax({
                url: "../RenYuan/GetSelZhanDui",
                data: { "ZhanQuId": $("#SelZhanQu2").val() },
                type: "post",
                dataType: "json",
                success: function (response) {
                    if ($("#SelZhanQu").val() != 0) {
                        var ddl = $("#SelZhanDui2");
                        var opt0 = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt0);
                    }
                    $(response).each(function (key) {
                        if (response[key].id.toString() == '1') {
                            var opt = $("<option></option>").text("请选择").val(response[key].id);
                            ddl.append(opt);
                        } else if (response[key].id.toString() == "") {
                            var opt = $("<option selected='selected'></option>").text(response[key].ZhanDuiMingCheng).val(response[key].id);
                            ddl.append(opt);
                        } else {
                            var opt = $("<option></option>").text(response[key].ZhanDuiMingCheng).val(response[key].id);
                            ddl.append(opt);
                        }
                    })
                    console.log(response);
                }
            });
        })
        //修改下拉框绑定3
        $('#selxiaoqu').bind('input propertychange', function () {
            $("#sellouhao").empty();
            $("#selceng").empty();
            $("#selmen").empty();
            $("#zhuangtai").text("");
            $.ajax({
                url: "../KeHu/BindSelLouHao",
                type: "post",
                data: { "XiaoQuId": $("#selxiaoqu").val() },
                dataType: "json",
                success: function (response) {
                    if ($("#selxiaoqu").val() != 0) {
                        var ddl = $("#sellouhao");
                        var opt0 = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt0);
                    }
                    $(response).each(function (key) {
                        var opt = $("<option></option>").text(response[key].LouHao + "号楼").val(response[key].LouHao);
                        ddl.append(opt);
                    })
                }
            });
        })
        //修改下拉框绑定3
        $('#sellouhao').bind('input propertychange', function () {
            $("#selceng").empty();
            $("#selmen").empty();
            $("#zhuangtai").text("");
            $.ajax({
                url: "../KeHu/BindSelCeng",
                type: "post",
                data: { "LouHao": $("#sellouhao").val(), "XiaoQuId": $("#selxiaoqu").val() },
                dataType: "json",
                success: function (response) {
                    if ($("#sellouhao").val() != 0) {
                        var ddl = $("#selceng");
                        var opt0 = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt0);
                    }
                    $(response).each(function (key) {
                        var opt = $("<option></option>").text(response[key].Ceng + "层").val(response[key].Ceng);
                        ddl.append(opt);
                    })
                }
            });
        })
        //修改下拉框绑定3
        $('#selceng').bind('input propertychange', function () {
            $("#selmen").empty();
            $("#zhuangtai").text("");
            $.ajax({
                url: "../KeHu/BindSelMen",
                type: "post",
                data: { "LouHao": $("#sellouhao").val(), "XiaoQuId": $("#selxiaoqu").val(), "Ceng": $("#selceng").val() },
                dataType: "json",
                success: function (response) {
                    if ($("#selceng").val() != 0) {
                        var ddl = $("#selmen");
                        var opt0 = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt0);
                    }
                    $(response).each(function (key) {
                        var opt = $("<option></option>").text(response[key].Men + "门").val(response[key].Men);
                        ddl.append(opt);
                    })
                }
            });
        })

        //调用房源绑定
        xianqu()
        //调用公司绑定
        BindDpGongSi("");
        //调用人员列表
        bang('不查');
        bang2('不查');
        //调用小区绑定
        BindSelXiaoQu()

        //修改下拉框事件
        document.getElementById('SelGongSi').onchange = function () {
            bang('查')
        };
        //修改下拉框事件1
        document.getElementById('SelZhanQu').onchange = function () {
            bang('查')
        };
        //修改下拉框事件1
        document.getElementById('SelZhanDui').onchange = function () {
            bang('查')
        };
        //修改下拉框事件2
        document.getElementById('SelZhanQu2').onchange = function () {
            bang2('查')
        };
        //修改下拉框事件2
        document.getElementById('SelZhanDui2').onchange = function () {
            bang2('查')
        };
        //修改下拉框事件3 调用房源状态
        document.getElementById('selmen').onchange = function () {
            if ($("#selmen").find("option:selected").val() != 0) {
                zhuangtai();
            } else {
                $("#zhuangtai").text("");
            }

        };

    });


    //客户确定
    function queding() {
        if ($.trim($("#txt_KeHuXingMing").val()).length == 0) {
            swal("失败提示!", "姓名不能为空!", "error");
            return;
        } if ($.trim($("#dl_XingBie").find("option:selected").val()).length == 0) {
            swal("失败提示!", "性别不能为空!", "error");
            return;
        } if ($.trim($("#txt_NianLing").val()).length == 0) {
            swal("失败提示!", "年龄不能为空!", "error");
            return;
        } if (!(/^1[3456789]\d{9}$/.test($("#txt_ShouJiHaoMa").val()))) {
            swal("失败提示!", "请输入正确的手机号码!", "error");
            return;
        }
        $("#txt_KeHuXingMing").attr("disabled", "disabled");
        $("#dl_XingBie").attr("disabled", "disabled");
        $("#txt_NianLing").attr("disabled", "disabled");
        $("#txt_ShouJiHaoMa").attr("disabled", "disabled");
        $("#i_slt_xiaoqu").attr("disabled", "disabled");
    }
    //客户修改
    function xiugai() {
        $("#txt_KeHuXingMing").removeAttr("disabled", "disabled");
        $("#dl_XingBie").removeAttr("disabled", "disabled");
        $("#txt_NianLing").removeAttr("disabled", "disabled");
        $("#txt_ShouJiHaoMa").removeAttr("disabled", "disabled");
        $("#i_slt_xiaoqu").removeAttr("disabled", "disabled");
    }


    //调用添加客户 清空弹层信息
    function quedingxixin() {
        //文本框清空
        $("#selxiaoqu").val(0);
        $("#sellouhao").empty();
        $("#selceng").empty();
        $("#selmen").empty();
        $("#zhuangtai").text("");
        $("#iptmoney").val("");
        //错误提示
        if ($.trim($("#txt_KeHuXingMing").val()).length == 0) {
            swal("失败提示!", "请检查客户信息!", "error");
            return;
        } if ($.trim($("#dl_XingBie").find("option:selected").val()).length == 0) {
            swal("失败提示!", "请检查客户信息!", "error");
            return;
        } if ($.trim($("#txt_NianLing").val()).length == 0) {
            swal("失败提示!", "请检查客户信息!", "error");
            return;
        } if (!(/^1[3456789]\d{9}$/.test($("#txt_ShouJiHaoMa").val()))) {
            swal("失败提示!", "请检查客户手机号码!", "error");
            return;
        } if ($.trim($("#i_ipt_zhiyeguwen").val()).length == 0) {
            swal("失败提示!", "置业顾问不能为空!", "error");
            return;
        }
        //点击弹层
        $("#btn_Xz").trigger("click");
    }

    //重写添加
    function chongxietianjia() {
        var XingMing = $("#txt_KeHuXingMing").val();
        var ShouJiHaoMa = $("#txt_ShouJiHaoMa").val();
        var XingBie = $("#dl_XingBie").find("option:selected").val();
        var NianLing = $("#txt_NianLing").val();
        var yewuyuan = $("#i_ipt_yewuyuanId").val();
        var zhiyeguwen = $("#i_ipt_zhiyeguwenId").val();
        $("#i_btn_queding2").attr("disabled", "disabled");
        if ($("#selxiaoqu").val() == "请选择" || $("#selxiaoqu").val() == undefined || $("#selxiaoqu").val() == "") {
            alert('请选择小区！');
        } else if ($("#sellouhao").val() == "请选择" || $("#sellouhao").val() == undefined || $("#sellouhao").val() == "") {
            alert('请选择楼号！');
        } else if ($("#selceng").val() == "请选择" || $("#selceng").val() == undefined || $("#selceng").val() == "") {
            alert('请选择层！');
        } else if ($("#selmen").val() == "请选择" || $("#selmen").val() == undefined || $("#selmen").val() == "") {
            alert('请选择门！');
        } else {
            $.ajax({
                type: "POST",
                url: "../KeHu/chongxietianjia",
                cache: false,  //禁用缓存
                data: { "XingMing": "" + XingMing + "", "ShouJiHaoMa": "" + ShouJiHaoMa + "", "NianLing": "" + NianLing + "", "XingBie": "" + XingBie + "", "yewuyuan": "" + yewuyuan + "", "zhiyeguwen": "" + zhiyeguwen + "", "XiaoQuId": $("#selxiaoqu").val(), "LouHao": $("#sellouhao").val(), "Ceng": $("#selceng").val(), "Men": $("#selmen").val(), ChengJiaoJinE: $("#iptmoney").val() },  //传入组装的参数
                dataType: "text",
                success: function (result) {
                    $("#bt_ChongZhiE").removeAttr("disabled", "disabled");
                    if (result == -1) {
                        alert("添加成功!");
                        window.location.href = 'KeHuBuLu';
                    } else if (result == -3) {
                        swal("失败提示!", "客户失败!", "error");
                    } else if (result == -4) {
                        swal("失败提示!", "销售失败!", "error");
                    } else if (result == -5) {
                        swal("失败提示!", "销售详细失败!", "error");
                    } else if (result == -6) {
                        swal("失败提示!", "房源客户失败!", "error");
                    } else if (result == -7) {
                        swal("失败提示!", "房源失败!", "error");
                    } else {
                        var isClick = confirm("客户已经存在，请去数据中心添加数据!");
                        if (isClick) {
                            window.location.href = 'ShuJuZhongXin?Id=' + result;
                        } else {
                            $("#guanbiaddkehu").trigger("click");
                            //window.location.href = 'KeHuBuLu';
                        }
                        //swal("失败提示!", "客户已经存在，请去数据中心添加数据!", "error");
                    }
                    $("#i_btn_queding2").removeAttr("disabled", "disabled")
                }
            })
        }
    }


    //房源绑定
    function xianqu() {
        $.ajax({
            type: "POST",
            url: "../PhoneKeHu/fanyuanliebiao",
            cache: false,  //禁用缓存
            dataType: "json",
            success: function (date) {
                var XLK = $("#i_slt_xiaoqu");
                $(date).each(function (key) {
                    var opt = $("<option></option>").text(date[key].XiaoQuMingCheng).val(date[key].Id);
                    XLK.append(opt);
                })
            }
        });
    }
    //公司绑定
    function BindDpGongSi(GongSiId) {
        $.ajax({
            url: "../RenYuan/GetSelGongSi",
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelGongSi");
                var opt0 = $("<option></option>").text("请选择").val('0');
                ddl.append(opt0);
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else if (response[key].Id.toString() == GongSiId.toString()) {
                        var opt = $("<option selected='selected'></option>").text(response[key].GongSiMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].GongSiMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
        $.ajax({
            url: "../RenYuan/GetSelZhanQu",
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelZhanQu");
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].ZhanQuMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
        $.ajax({
            url: "../RenYuan/GetSelZhanQu",
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelZhanQu2");
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].ZhanQuMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
    }
    //小区绑定
    function BindSelXiaoQu() {
        $.ajax({
            url: "../KeHu/BindSelXiaoQu",
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#selxiaoqu");
                var opt = $("<option></option>").text("请选择").val(0);
                ddl.append(opt);
                $(response).each(function (key) {
                    var opt = $("<option></option>").text(response[key].XiaoQuMingCheng).val(response[key].Id);
                    ddl.append(opt);
                })
                console.log(response);
            }
        });
    }



    //绑定业务员列表
    function bang(panduan) {
        var selGongSi = "0";
        var selZhanQu = "0";
        var selZhanDui = "0";
        if (panduan == "查") {
            selGongSi = $("#SelGongSi").find("option:selected").val();
            selZhanQu = $("#SelZhanQu").find("option:selected").val();;
            selZhanDui = $("#SelZhanDui").find("option:selected").val();;
        } else if (panduan == "不查") {
            selGongSi = "0";
            selZhanQu = "0";
            selZhanDui = "0";
        }
        var lang = {
            "sProcessing": "大量处理中，请稍后...",
            "sLengthMenu": "每页 _MENU_ 项",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
            "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页",
                "sJump": "跳转"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        };
        $("#dataTableExample").dataTable().fnDestroy();
        $('#dataTableExample').dataTable({
            "order": [[1, "asc"]],
            "language": lang,
            "processing": true,
            "serverSide": true,
            //"bStateSave": true,//状态保持模式
            "searching": false,//禁用搜索
            ajax: function (data, callback, settings) {
                //封装请求参数
                //console.log(data);
                var param = {};
                param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.page = (data.start / data.length) + 1;//当前页码
                param.dir = data.order[0].dir;
                param.column = data.order[0].column;
                //param.xingming = xingming;
                param.selZhanQu = selZhanQu;
                param.selZhanDui = selZhanDui;
                param.selGongSi = selGongSi;
                //param.selBuMen = selBuMen;
                param.selGangWei = 32;
                param.ZhuangTai = '';
                //console.log(param);

                //ajax请求数据
                $.ajax({
                    type: "POST",
                    url: "../RenYuan/InitializationDataTable",
                    cache: false,  //禁用缓存
                    data: param,  //传入组装的参数
                    dataType: "json",
                    success: function (result) {
                        console.log(result);
                        //setTimeout仅为测试延迟效果
                        setTimeout(function () {
                            //封装返回数据
                            var returnData = {};
                            returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                            returnData.recordsTotal = result.total;//返回数据全部记录
                            returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = result.data;//返回的数据列表
                            //console.log(returnData);
                            //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                            //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕"orderable" : false
                            callback(returnData);
                        }, 200);
                    }
                });
            },
            "columns": [
                { "data": "XingMing" },
                { "data": "NianLing" },
                { "data": "XingBie" },
                { "data": "LianXiFangShi" },
                //{ "data": "t_GangWeiBiao.t_BuMenBiao.BuMenMingCheng" },
                //{ "data": "t_GangWeiBiao.GangWeiMingCheng" },
                //{ "data": "t_GangWeiBiao.t_BuMenBiao.t_GongSiBiao.GongSiMingCheng" },
                //{ "data": "t_ZhanDuiBiao.t_ZhanQuBiao.ZhanQuMingCheng" },
                //{ "data": "t_ZhanDuiBiao.ZhanDuiMingCheng" },
                //{ "data": "ShenFenZhengHao" },
                { "data": null }
            ],
            columnDefs: [{
                //   指定第最后一列
                targets: -1,
                //加下面属性 不参与排序
                sortable: false,
                render: function (data, type, row, meta) {
                    if (row.t_GangWeiBiao.GangWeiMingCheng == "业务员") {
                        return '<button type="button" class="btn btn-outline btn-default" onclick="fuzhiyewuyuanmingzi(' + row.Id + ');">添加业务员</button><span id="' + row.Id + '" hidden="hidden">' + row.XingMing + '</span>';
                    } else if (row.t_GangWeiBiao.GangWeiMingCheng == "置业顾问") {
                        return '<button type="button" class="btn btn-outline btn-default" onclick="fuzhizhiyeguwenmingzi(' + row.Id + ');">添加置业顾问</button><span id="' + row.Id + '" hidden="hidden">' + row.XingMing + '</span>';
                    } else {
                        return '';
                    }
                }
            }]
        });
    }
    //绑定置业顾问列表
    function bang2(panduan) {
        var selGongSi = "0";
        var selZhanQu = "0";
        var selZhanDui = "0";
        if (panduan == "查") {
            selGongSi = $("#SelGongSi").find("option:selected").val();
            selZhanQu = $("#SelZhanQu2").find("option:selected").val();;
            selZhanDui = $("#SelZhanDui2").find("option:selected").val();;
        } else if (panduan == "不查") {
            selGongSi = "0";
            selZhanQu = "0";
            selZhanDui = "0";
        }
        var lang = {
            "sProcessing": "大量处理中，请稍后...",
            "sLengthMenu": "每页 _MENU_ 项",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
            "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页",
                "sJump": "跳转"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        };
        $("#dataTableExample2").dataTable().fnDestroy();
        $('#dataTableExample2').dataTable({
            "order": [[1, "asc"]],
            "language": lang,
            "processing": true,
            "serverSide": true,
            //"bStateSave": true,//状态保持模式
            "searching": false,//禁用搜索
            ajax: function (data, callback, settings) {
                //封装请求参数
                //console.log(data);
                var param = {};
                param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.page = (data.start / data.length) + 1;//当前页码
                param.dir = data.order[0].dir;
                param.column = data.order[0].column;
                //param.xingming = xingming;
                param.selZhanQu = selZhanQu;
                param.selZhanDui = selZhanDui;
                param.selGongSi = selGongSi;
                //param.selBuMen = selBuMen;
                param.selGangWei = 34;
                param.ZhuangTai = '';
                //console.log(param);

                //ajax请求数据
                $.ajax({
                    type: "POST",
                    url: "../RenYuan/InitializationDataTable",
                    cache: false,  //禁用缓存
                    data: param,  //传入组装的参数
                    dataType: "json",
                    success: function (result) {
                        console.log(result);
                        //setTimeout仅为测试延迟效果
                        setTimeout(function () {
                            //封装返回数据
                            var returnData = {};
                            returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                            returnData.recordsTotal = result.total;//返回数据全部记录
                            returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = result.data;//返回的数据列表
                            //console.log(returnData);
                            //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                            //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕"orderable" : false
                            callback(returnData);
                        }, 200);
                    }
                });
            },
            "columns": [
                { "data": "XingMing" },
                { "data": "NianLing" },
                { "data": "XingBie" },
                { "data": "LianXiFangShi" },
                //{ "data": "t_GangWeiBiao.t_BuMenBiao.BuMenMingCheng" },
                //{ "data": "t_GangWeiBiao.GangWeiMingCheng" },
                //{ "data": "t_GangWeiBiao.t_BuMenBiao.t_GongSiBiao.GongSiMingCheng" },
                //{ "data": "t_ZhanDuiBiao.t_ZhanQuBiao.ZhanQuMingCheng" },
                //{ "data": "t_ZhanDuiBiao.ZhanDuiMingCheng" },
                //{ "data": "ShenFenZhengHao" },
                { "data": null }
            ],
            columnDefs: [{
                //   指定第最后一列
                targets: -1,
                //加下面属性 不参与排序
                sortable: false,
                render: function (data, type, row, meta) {
                    if (row.t_GangWeiBiao.GangWeiMingCheng == "业务员") {
                        return '<button type="button" class="btn btn-outline btn-default" onclick="fuzhiyewuyuanmingzi(' + row.Id + ');">添加业务员</button><span id="' + row.Id + '" hidden="hidden">' + row.XingMing + '</span>';
                    } else if (row.t_GangWeiBiao.GangWeiMingCheng == "置业顾问") {
                        return '<button type="button" class="btn btn-outline btn-default" onclick="fuzhizhiyeguwenmingzi(' + row.Id + ');">添加置业顾问</button><span id="' + row.Id + '" hidden="hidden">' + row.XingMing + '</span>';
                    } else {
                        return '';
                    }
                }
            }]
        });
    }



    //赋值业务员姓名存id
    function fuzhiyewuyuanmingzi(Id) {
        $("#i_ipt_yewuyuan").val($("#" + Id + "").text());
        $("#i_ipt_yewuyuanId").val(Id);
    }
    //赋值置业顾问姓名存id
    function fuzhizhiyeguwenmingzi(Id) {
        $("#i_ipt_zhiyeguwen").val($("#" + Id + "").text());
        $("#i_ipt_zhiyeguwenId").val(Id);
    }

    //房源状态
    function zhuangtai() {
        $.ajax({
            type: "POST",
            url: "../KeHu/fangyuanzhuangtai",
            cache: false,  //禁用缓存
            data: { "LouHao": $("#sellouhao").val(), "XiaoQuId": $("#selxiaoqu").val(), "Ceng": $("#selceng").val(), "Men": $("#selmen").val() },  //传入组装的参数
            dataType: "text",
            success: function (result) {
                $("#zhuangtai").text(result);
                if (result != "未出售") {
                    $("#i_btn_queding2").attr("disabled", "disabled");
                } else {
                    $("#i_btn_queding2").removeAttr("disabled", "disabled");
                }
            }
        })
    }
    //重置
    function chongzhi() {
        $("#i_ipt_yewuyuan").val("");
        $("#i_ipt_yewuyuanId").val("");
        $("#i_ipt_zhiyeguwen").val("");
        $("#i_ipt_zhiyeguwenId").val("");
        $("#i_ipt_zhiyeguwenId").val("");
        $("#SelGongSi").val(0);
        $("#SelZhanQu").val(0);
        $("#SelZhanQu2").val(0);
        $("#SelZhanDui").empty();
        $("#SelZhanDui2").empty();
    }
    //清空
    function qingkong() {
        $("#txt_KeHuXingMing").val("");
        $("#dl_XingBie").val("男");
        $("#txt_NianLing").val("");
        $("#txt_ShouJiHaoMa").val("");

        $("#i_ipt_yewuyuan").val("");
        $("#i_ipt_yewuyuanId").val("");
        $("#i_ipt_zhiyeguwen").val("");
        $("#i_ipt_zhiyeguwenId").val("");
        $("#i_ipt_zhiyeguwenId").val("");
        $("#SelGongSi").val(0);
        $("#SelZhanQu").val(0);
        $("#SelZhanQu2").val(0);
        $("#SelZhanDui").empty();
        $("#SelZhanDui2").empty();
    }


    //获取地址栏值
    function getQuery(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }
</script>
<input type="text" id="kehuid" hidden="hidden" />
<input type="text" id="xiaoshouid" hidden="hidden" />
<div id="i_dv_jia" class="page-container">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">客户补录管理</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">客户补录管理</a>
                </li>
                <li class="breadcrumb-item active">客户补录信息</li>
            </ol>
        </div>
        <div class="page-content">

            <div class="panel">
                <div class="panel-body container-fluid" style="padding:0px 25px">
                    <div class="row row-lg">
                        <div class="col-md-12">
                            <div class="example-wrap">
                                <div class="example">
                                    <div autocomplete="off">
                                        <h3 class="example-title">客户信息</h3>
                                        <div class="row">
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_KeHuXingMing">姓名</label>
                                                <input type="text" class="form-control" id="txt_KeHuXingMing" name="txt_KeHuXingMing" placeholder="姓名" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_XingBie">性别</label>
                                                <select class="form-control" id="dl_XingBie"><option value="男">男</option><option value="女">女</option></select>
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_NianLing">年龄</label>
                                                <input type="text" class="form-control" id="txt_NianLing" name="txt_NianLing" placeholder="年龄" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_LianXiFangShi">手机号码</label>
                                                <input type="text" class="form-control" id="txt_ShouJiHaoMa" name="txt_ShouJiHaoMa" placeholder="手机号码" autocomplete="off">
                                            </div>
                                            <!--<div--> @*class="form-group col-sm-3"*@
                                            <!--style="width:18%;margin-left:2.5%">
                                                <label>意向小区<span style="color:red;"></span></label>
                                                <select id="i_slt_xiaoqu" class="form-control">
                                                </select>
                                            </div>-->
                                            <div class="form-group col-sm-12" style="padding-top:27px">
                                                <button type="button" class="btn btn-primary" onclick="queding()" style="width:49%">确定</button>
                                                <button type="button" class="btn btn-primary" onclick="xiugai()" style="width:49%">修改</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel">
                <div class="panel-body container-fluid" style="padding:0px 25px">
                    <div class="row row-lg">
                        <div class="col-md-12">
                            <div class="example-wrap">
                                <div class="example">
                                    <div autocomplete="off">
                                        <h3 class="example-title">人员信息</h3>
                                        <div class="row">
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_XingBie">业务员</label>
                                                <input id="i_ipt_yewuyuan" class="form-control" disabled="disabled" />
                                                <input id="i_ipt_yewuyuanId" class="form-control" hidden="hidden" />
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_XingBie">置业顾问</label>
                                                <input id="i_ipt_zhiyeguwen" class="form-control" disabled="disabled" />
                                                <input id="i_ipt_zhiyeguwenId" class="form-control" hidden="hidden" />
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_XingBie">公司</label>
                                                <select id="SelGongSi" class="form-control"></select>
                                            </div>
                                            <div class="form-group col-sm-3" style="padding-top:27px">
                                                <button type="button" id="i_btn_queding" class="btn btn-primary" onclick="quedingxixin()" style="width:100%">确定</button>
                                                <a title="" data-target="#exampleFormModal" data-toggle="modal" id="btn_Xz"></a>
                                            </div>
                                            <div class="form-group col-sm-3" style="padding-top:27px">
                                                <button type="button" class="btn btn-primary" onclick="chongzhi()" style="width:100%">重置</button>
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <div class="row" style="margin:10px;">
                                                    <div class="form-group col-sm-4">
                                                        <label class="col-form-label" for="for_XingBie">战区</label>
                                                        <select id="SelZhanQu" class="form-control">
                                                            <option value="0">请选择</option>
                                                        </select>
                                                    </div>
                                                    <div class="form-group col-sm-4">
                                                        <label class="col-form-label" for="for_XingBie">战队</label>
                                                        <select id="SelZhanDui" class="form-control">
                                                            @*<option value="0">请选择</option>*@
                                                        </select>
                                                    </div>
                                                    <div class="form-group col-sm-2"></div>
                                                    <table class="table table-bordered table-hover dataTable table-striped w-full text-nowrap" id="dataTableExample" data-plugin="dataTable">
                                                        <thead>
                                                            <tr>
                                                                <th>姓名</th>
                                                                <th>年龄</th>
                                                                <th>性别</th>
                                                                <th>联系方式</th>
                                                                @*<th>部门</th>*@
                                                                @*<th>岗位</th>*@
                                                                @*<th>公司</th>*@
                                                                @*<th>身份证号</th>*@
                                                                <th>操作</th>
                                                            </tr>
                                                        </thead>
                                                        <tfoot>
                                                            <tr>
                                                                <th>姓名</th>
                                                                <th>年龄</th>
                                                                <th>性别</th>
                                                                <th>联系方式</th>
                                                                @*<th>部门</th>*@
                                                                @*<th>岗位</th>*@
                                                                @*<th>公司</th>*@
                                                                @*<th>身份证号</th>*@
                                                                <th>操作</th>
                                                            </tr>
                                                        </tfoot>
                                                        <tbody></tbody>
                                                    </table>
                                                </div>
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <div class="row" style="margin:10px;">
                                                    <div class="form-group col-sm-4">
                                                        <label class="col-form-label" for="for_XingBie">战区</label>
                                                        <select id="SelZhanQu2" class="form-control">
                                                            <option value="0">请选择</option>
                                                        </select>
                                                    </div>
                                                    <div class="form-group col-sm-4">
                                                        <label class="col-form-label" for="for_XingBie">战队</label>
                                                        <select id="SelZhanDui2" class="form-control">
                                                            @*<option value="0">请选择</option>*@
                                                        </select>
                                                    </div>
                                                    <div class="form-group col-sm-2"></div>
                                                    <table class="table table-bordered table-hover dataTable table-striped w-full text-nowrap" id="dataTableExample2" data-plugin="dataTable">
                                                        <thead>
                                                            <tr>
                                                                <th>姓名</th>
                                                                <th>年龄</th>
                                                                <th>性别</th>
                                                                <th>联系方式</th>
                                                                @*<th>部门</th>*@
                                                                @*<th>岗位</th>*@
                                                                @*<th>公司</th>*@
                                                                @*<th>身份证号</th>*@
                                                                <th>操作</th>
                                                            </tr>
                                                        </thead>
                                                        <tfoot>
                                                            <tr>
                                                                <th>姓名</th>
                                                                <th>年龄</th>
                                                                <th>性别</th>
                                                                <th>联系方式</th>
                                                                @*<th>部门</th>*@
                                                                @*<th>岗位</th>*@
                                                                @*<th>公司</th>*@
                                                                @*<th>身份证号</th>*@
                                                                <th>操作</th>
                                                            </tr>
                                                        </tfoot>
                                                        <tbody></tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade example-modal-lg" id="exampleFormModal" aria-hidden="true" aria-labelledby="exampleFormModalLabel" role="dialog" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog modal-lg" style="width: 100%; height: 80%">
        <div class="modal-content" style="width: 100%; height: 90%">
            <div class="modal-header" style="background-color:#0099FF">
                <label id="CunId" style="display:none"></label>
                <button type="button" class="close" data-dismiss="modal" id="guanbiaddkehu" onclick="" aria-label="关闭">
                    <span aria-hidden="true" onclick="">×</span>
                </button>
                <h4 class="modal-title" id="exampleFormModalLabel">选择房源</h4>
            </div>
            <div class="row">
                <div class="form-group col-sm-12"></div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10"></div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">小区名称</label>
                    <select class="form-control" id="selxiaoqu" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                </div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">楼号</label>
                    <select class="form-control" id="sellouhao" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                </div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">层</label>
                    <select class="form-control" id="selceng" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                </div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">门</label>
                    <select class="form-control" id="selmen" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                </div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10" style="margin-top:27px;">
                    <label class="control-label" for="inputBasicPassword" id="zhuangtai"></label>
                </div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">成交金额</label>
                    <input type="text" name="asdf" id="iptmoney" class="form-control" value="" />
                </div>
                <div class="form-group col-sm-3"></div>
                <div class="form-group col-sm-6">
                    <button type="button" id="i_btn_queding2" class="btn btn-outline btn-success" style="width: 100%;" onclick="chongxietianjia();">确定</button>
                </div>
                <div class="form-group col-sm-3"></div>
            </div>
        </div>
    </div>
</div>



@*////添加客户 调用 添加销售
    //function Add() {
    //    $("#i_btn_queding").attr("disabled", "disabled");
    //    var XingMing = $("#txt_KeHuXingMing").val();
    //    var ShouJiHaoMa = $("#txt_ShouJiHaoMa").val();
    //    var XingBie = $("#dl_XingBie").find("option:selected").val();
    //    var NianLing = $("#txt_NianLing").val();
    //    var xiaoqu = $("#i_slt_xiaoqu").find("option:selected").val();
    //    var yewuyuan = $("#i_ipt_yewuyuanId").val();
    //    var zhiyeguwen = $("#i_ipt_zhiyeguwenId").val();

    //    if ($.trim(XingMing).length == 0) {
    //        swal("失败提示!", "姓名不能为空!", "error");
    //        return;
    //    } if (!(/^1[3456789]\d{9}$/.test(ShouJiHaoMa))) {
    //        swal("失败提示!", "请输入正确的手机号码!", "error");
    //        return;
    //    }
    //    //$.ajax({
    //    //    type: "POST",
    //    //    url: "../KeHu/AddKeHu2",
    //    //    cache: false,  //禁用缓存
    //    //    data: { "XingMing": "" + XingMing + "", "ShouJiHaoMa": "" + ShouJiHaoMa + "", "NianLing": "" + NianLing + "", "XingBie": "" + XingBie + "","yewuyuan": "" + yewuyuan + "", "zhiyeguwen": "" + zhiyeguwen + "", "XiaoQu": "" + xiaoqu + "" },  //传入组装的参数
    //    //    dataType: "text",
    //    //    success: function (result) {
    //    //        if (result == "error") {
    //    //            swal("失败提示!", "保存客户信息失败!", "error");
    //    //        } else if (result == "errorShouJi") {
    //    //            swal("失败提示!", "该手机号和意向小区已存在!", "error");
    //    //        } else {
    //    //            $("#kehuid").val(result);
    //    //            if ($("#kehuid").val() > 0) {
    //    //                tianjia();
    //    //            }
    //    //        }
    //    //    }
    //    //});
    //}
    ////添加销售
    //function tianjia(kehuid) {
    //    var yewuyuan = $("#i_ipt_yewuyuanId").val();
    //    var zhiyeguwen = $("#i_ipt_zhiyeguwenId").val();
    //    if (yewuyuan.length == 0) {
    //        swal("失败提示!", "业务员不能为空!", "error");
    //        return;
    //    } if (zhiyeguwen.length == 0) {
    //        swal("失败提示!", "置业顾问不能为空!", "error");
    //        return;
    //    }
    //    //$.ajax({
    //    //    type: "POST",
    //    //    url: "../KeHu/tianjiaxiaoshou",
    //    //    cache: false,  //禁用缓存
    //    //    data: { "yewuyuan": "" + yewuyuan + "", "zhiyeguwen": "" + zhiyeguwen + "", "kehuid": "" + $("#kehuid").val() + "" },  //传入组装的参数
    //    //    dataType: "text",
    //    //    success: function (result) {
    //    //        if (result == "销售失败") {
    //    //            swal("失败提示!", "销售失败!", "error");
    //    //        } else if (result == "销售详细失败") {
    //    //            swal("失败提示!", "销售详细失败!", "error");
    //    //        } else {
    //    //            $("#xiaoshouid").val(result);
    //    //            if ($("#xiaoshouid").val() > 0) {
    //    //                $("#btn_Xz").trigger("click");
    //    //            }
    //    //        }
    //    //        $("#i_btn_queding").removeAttr("disabled", "disabled")
    //    //    }
    //    //});
    //}
    ////添加房屋
    //function SubmitUpdate() {
    //    $("#bt_ChongZhiE").attr("disabled", "disabled");
    //    if ($("#selxiaoqu").val() == "请选择" || $("#selxiaoqu").val() == undefined || $("#selxiaoqu").val() == "") {
    //        alert('请选择小区！');
    //    } else if ($("#sellouhao").val() == "请选择" || $("#sellouhao").val() == undefined || $("#sellouhao").val() == "") {
    //        alert('请选择楼号！');
    //    } else if ($("#selceng").val() == "请选择" || $("#selceng").val() == undefined || $("#selceng").val() == "") {
    //        alert('请选择层！');
    //    } else if ($("#selmen").val() == "请选择" || $("#selmen").val() == undefined || $("#selmen").val() == "") {
    //        alert('请选择门！');
    //    } else {
    //        $("#bt_ChongZhiE").attr("disabled", "disabled");
    //        $.ajax({
    //            type: "POST",
    //            url: "../KeHu/UpdateKeHu3",
    //            cache: false,  //禁用缓存
    //            data: { ChengJiaoJinE: $("#iptmoney").val(), Id: $("#IptId").val(), zhuangtaiya: $("#IptPanDuan").val(), "LouHao": $("#sellouhao").val(), "XiaoQuId": $("#selxiaoqu").val(), "Ceng": $("#selceng").val(), "Men": $("#selmen").val(), "xiaoshouid": $("#xiaoshouid").val(), "kehuid": $("#kehuid").val(), "shoujihao": "" + $("#txt_ShouJiHaoMa").val() + "" },  //传入组装的参数
    //            dataType: "text",
    //            success: function (result) {
    //                $("#bt_ChongZhiE").removeAttr("disabled", "disabled");
    //                if (result == -2) {
    //                    swal("失败提示!", "该房屋已经出售或是审核中!", "error");
    //                } else if (result == -3) {
    //                    swal("失败提示!", "客户修改失败!", "error");
    //                } else if (result == -4) {
    //                    swal("失败提示!", "销售详细信息失败!", "error");
    //                } else if (result == -5) {
    //                    swal("失败提示!", "销售信息失败!", "error");
    //                } else if (result == -6) {
    //                    swal("失败提示!", "房屋信息失败!", "error");
    //                } else if (result == -7) {
    //                    swal("失败提示!", "房源客户信息失败!", "error");
    //                } else if (result == -8) {
    //                    swal("失败提示!", "已存在同手机号码购买当前小区房子请完成后，重新添加客户!", "error");
    //                } else {
    //                    //swal("成功提示!", "保存成功!", "success");
    //                    //var result = confirm('补录成功！');
    //                    //var result = swal("成功提示!", "保存成功!", "success");
    //                    //if (result) {
    //                    window.location.href = 'KeHuBuLu';
    //                    //}
    //                }
    //                $("#bt_ChongZhiE").removeAttr("disabled", "disabled")
    //            }
    //        })
    //    }
    //}*@